package com.ruoyi.teach.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teach.domain.CrmCustomerReview;
import com.ruoyi.teach.service.ICrmCustomerReviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户回访记录Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@RestController
@RequestMapping("/teach/review")
public class CrmCustomerReviewController extends BaseController
{
    @Autowired
    private ICrmCustomerReviewService crmCustomerReviewService;

    /**
     * 查询客户回访记录列表
     */
    @PreAuthorize("@ss.hasPermi('teach:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmCustomerReview crmCustomerReview)
    {
        startPage();
        List<CrmCustomerReview> list = crmCustomerReviewService.selectCrmCustomerReviewList(crmCustomerReview);
        return getDataTable(list);
    }

    /**
     * 导出客户回访记录列表
     */
    @PreAuthorize("@ss.hasPermi('teach:review:export')")
    @Log(title = "客户回访记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmCustomerReview crmCustomerReview)
    {
        List<CrmCustomerReview> list = crmCustomerReviewService.selectCrmCustomerReviewList(crmCustomerReview);
        ExcelUtil<CrmCustomerReview> util = new ExcelUtil<CrmCustomerReview>(CrmCustomerReview.class);
        util.exportExcel(response, list, "客户回访记录数据");
    }

    /**
     * 获取客户回访记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('teach:review:query')")
    @GetMapping(value = "/{reId}")
    public AjaxResult getInfo(@PathVariable("reId") Long reId)
    {
        return AjaxResult.success(crmCustomerReviewService.selectCrmCustomerReviewByReId(reId));
    }

    /**
     * 新增客户回访记录
     */
    @PreAuthorize("@ss.hasPermi('teach:review:add')")
    @Log(title = "客户回访记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmCustomerReview crmCustomerReview)
    {
        return toAjax(crmCustomerReviewService.insertCrmCustomerReview(crmCustomerReview));
    }

    /**
     * 修改客户回访记录
     */
    @PreAuthorize("@ss.hasPermi('teach:review:edit')")
    @Log(title = "客户回访记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmCustomerReview crmCustomerReview)
    {
        return toAjax(crmCustomerReviewService.updateCrmCustomerReview(crmCustomerReview));
    }

    /**
     * 删除客户回访记录
     */
    @PreAuthorize("@ss.hasPermi('teach:review:remove')")
    @Log(title = "客户回访记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reIds}")
    public AjaxResult remove(@PathVariable Long[] reIds)
    {
        return toAjax(crmCustomerReviewService.deleteCrmCustomerReviewByReIds(reIds));
    }
}
